import { getBaseCategoryList, getBannerList, getFloorList } from 'api/home'
const state = {
  // 商品分类数据
  categoryList: [],
  // 轮播图数据
  bannerList: [],
  // 底部列表
  floorList: []
}

const mutations = {
  // 设置商品分类数据
  setBaseCategoryList (state, payload) {
    state.categoryList = payload
  },
  // 设置轮播图数据
  setBannerList (state, payload) {
    state.bannerList = payload
  },
  // floorList数据
  setFloorList (state, payload) {
    state.floorList = payload
  }
}
const actions = {
  // 得到商品分类数据
  async onGetBaseCategoryList ({ commit }) {
    const { data: res } = await getBaseCategoryList()
    commit('setBaseCategoryList', res.data)
  },
  // 得到轮播图数据
  async onGetBannerList ({ commit }) {
    const { data: res } = await getBannerList()
    commit('setBannerList', res.data)
  },
  // floor组件数据
  async onGetFloorList ({ commit }) {
    const { data: res } = await getFloorList()
    commit('setFloorList', res.data)
  }
}
const getters = {}
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
